package com.bookRecommend.controller;


import com.bookRecommend.commons.ResponseUtils;
import com.bookRecommend.model.Comment;
import com.bookRecommend.service.ICommentService;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/comment")
public class CommentController {

    @Resource
    ICommentService service;

    @RequestMapping()
    public ResponseUtils findAll(Integer pageNum, Integer size) {
        PageInfo<Comment> pageInfo = service.findPage(pageNum, size);
        if (pageInfo != null) {
            return ResponseUtils.success("查询成功！", pageInfo);
        }
        return ResponseUtils.failure("查询失败！");
    }

    @RequestMapping("/delete")
    public ResponseUtils remove(Integer id) {
        int flag = service.removeById(id);
        if (flag > 0) {
            return ResponseUtils.success("删除成功!");
        }
        return ResponseUtils.failure("删除失败！");
    }
}
